<template>
  <div>
    <h3>爆款推荐</h3>
    <div class="box" v-for="item in items" :key="item.id">
      <div @click="deta(item.id)" class="img">
        <img :src="item.pic" alt="" />
      </div>
      <div class="text">
        <h4>{{ item.name }}</h4>
       <div class="van-ellipsis text-m">
          商品细节:{{
            item.characteristic ? item.characteristic : '暂无细节描述'
          }}
       </div>
        <div class="icon">
          <div class="pic">价格:￥{{ item.minPrice }}</div>
          <div><van-icon @click="addcart(item.id)" name="shopping-cart-o" /></div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  props: {
    items: {
      type: Array,
      required: true
    }
  },
  methods: {
    deta (id) {
      this.$emit('details', id)
    },
    addcart (id) {
      this.$emit('addcart', id)
    }
  }
}
</script>

<style lang="scss" scoped>
h3{
    text-align: center;
    font-size: 30px;
    color: rgb(214, 63, 25);
}
.box {
  display: flex;
  justify-content: space-between;
  font-size: 20px;
  margin-top: 10px;
  .img {
    width: 160px;
    height: 140px;
    img {
      width: 100%;
      height: 100%;
    }
  }
  .text {
      width: 180px;
      display: flex;
      flex-direction: column;
      justify-content: space-around;
      h4{
        color: rgb(54, 63, 11);
      }
      .text-m{
          font-size: 16px;
      }
    .icon {
      padding-right: 10px;
      display: flex;
      justify-content: space-between;
      color: rgb(250, 10, 10);
      .pic{
        color: rgb(243, 88, 161);
      }
    }
  }
}
</style>
